package start.rabbitmq;

import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import java.util.Map;

@Slf4j
@Component
@RabbitListener(queues = "TestDirectQueue")//监听的队列名称 TestDirectQueue
public class RabbitConsumer {

    @RabbitHandler
    @SneakyThrows
    public void process(Map testMessage) {
        Thread.sleep(1*100);
        log.info("DirectReceiver消费者收到Map消息  : " + testMessage.toString());
    }

    @RabbitHandler
    @SneakyThrows
    public void process(String testMessage) {
        Thread.sleep(1*100);
        log.info("DirectReceiver消费者收到String消息  : " + testMessage.toString());
    }

    @RabbitHandler
    @SneakyThrows
    public void process(Integer testMessage) {
        Thread.sleep(1*100);
        log.info("DirectReceiver消费者收到Integer消息  : " + testMessage.toString());
    }

}